<?php
/* 
 * Categories for Products
 */
class Category {
  private $categoryId;
  private $name;
  private $description;

  function __construct($categoryId=null, $name=null, $description=null) {
    $this->categoryId = $categoryId;
    $this->name = $name;
    $this->description = $description;
  }

  public function getCategoryId() {
    return $this->categoryId;
  }

  public function setCategoryId($categoryId) {
    $this->categoryId = $categoryId;
  }

  public function getName() {
    return $this->name;
  }

  public function setName($name) {
    $this->name = $name;
  }

  public function getDescription() {
    return $this->description;
  }

  public function setDescription($description) {
    $this->description = $description;
  }


  public static function getCategories() {
    $sql= "Select CategoryId, Name, Description from Category order by Name";
    return Utilities::selectQuery($sql);
  }

  public static function getItemCategoryCounts() {
    $sql="Select a.Name as Category, a.CategoryId, Count(b.ProductId) as Count from Category a, Product b where a.CategoryId=b.CategoryId group by a.Name order by a.Name";
    return Utilities::selectQuery($sql);
  }

}
?>
